﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace Sucdri.Infrastructure.Core.Extensions
{

   public static class EnumerableExtensions
   {
      public static void AddRange<T>(this ICollection<T> source,ICollection<T> target)
      {
         if(source==null)
            throw new ArgumentNullException("source");
         if(!target.IsEmpty())
            foreach (var item in target)
            {
               source.Add(item);
            }
      }

      public static void SetValue<T>(this ICollection<T> source, ICollection<T> target)
      {
         if (source == null)
            throw new ArgumentNullException("source");
         if (!target.IsEmpty())
         {
            source=new Collection<T>();
            foreach (var item in target)
            {
               source.Add(item);
            }
         }
      }

      public static bool IsEmpty<T>(this IEnumerable<T> source)
      {
         if (source == null)
            return true;
         return !source.Any();
      }

   }
}
